#Project: Electoral Costs
#Author: Josh Ryan
#Working Date: Winter 2021
#Task: Create some graphs and other descriptive statistics
#Related files: working data, predictpartyunitywnom_stata_v3_021121.dta

library(foreign)
library(effects)
library(sciplot)
library(sandwich)
library(lmtest)   
library(BMS)
library(rJava)
library(lattice)
library(plyr)
library(lme4)
library(gmodels)
library(MASS)
library(stringr)
library("XLConnect")
library(reshape2)
library(xlsx)
library(dplyr)
library(doBy)
library(Hmisc)
library(stargazer)
library(xtable)
library(dplyr)
library(xtable)
library(foreign)
library(dotwhisker)#https://cran.r-project.org/web/packages/dotwhisker/vignettes/dotwhisker-vignette.html
library(berryFunctions) #for the insert row function
library(ggplot2)
library(gridExtra)
library(haven)
library(grid)
library(cowplot)
library(tigris)
library(tidycensus)
library(cdlTools)

#load working stata data
dat<-read_dta("predictpartyunitywnom_stata_v4_021721.dta")
ls(dat)

#####
#Appendix Tables and Graphs


#correlation between percentage of committee and party committee median--discussed in paper
#subset for each party
hdems<-subset(dat, memberparty==0)
#by congress-committee for dems when they are majority
hdems<-hdems %>% 
  distinct(cong, stewartcommid, .keep_all = T)
cor(hdems$commpartymedian, hdems$permaj,  use = "complete.obs")

hreps<-subset(dat, memberparty==1)
hreps<-hreps %>% 
  distinct(cong, stewartcommid, .keep_all = T)
cor(hreps$commpartymedian, hreps$permaj,  use = "complete.obs")

dat$memberparty<-as.factor(dat$memberparty)


#####
#Figure A1--Scatter Plot of District Partisanship and OC Z-Score by Legislator Party

labels<-subset(dat, memberparty==0 & dispart> .2 & mem_wnomsd> 2)

labels<-labels[c("cong", "stewartcommid", "lastname", "mem_wnomsd", "Committee", "st", "cdno", "memvoted", "withparty", "unity", "totvotes")]

dat$scatterlabel<-paste(dat$lastname, dat$Committee, dat$cong, sep=", ")
dat$scatterlabel<-str_to_title(dat$scatterlabel)

text_rep <- textGrob("More Republican", gp=gpar(fontsize=13))
text_dem <- textGrob("More Democratic", gp=gpar(fontsize=13))
text_con <- textGrob("More Conserative", gp=gpar(fontsize=13))
text_lib <- textGrob("More Liberal", gp=gpar(fontsize=13))

partyscatter<-ggplot(dat, aes(x=dispart, y=mem_wnomsd, group=memberparty)) +
  geom_point(aes(shape=memberparty, color=memberparty))+
  scale_color_manual(values=c('blue','red'), labels=c("Democrats", "Republicans"))+
  scale_shape_manual(values=c(19,17), labels=c("Democrats", "Republicans"))+
  labs(color = NULL)+ labs(shape = NULL)+
  scale_x_continuous(breaks=seq(-1, 1, .1))+ coord_cartesian(xlim=c(-1, 1)) +
  scale_y_continuous(breaks=seq(-2, 2, .5)) +
  coord_cartesian(ylim=c(-2, 2)) + theme_bw() +
  geom_text(aes(label=ifelse(mem_wnomsd< -1.7 & dispart< -.2,as.character(scatterlabel),'')),hjust=0,vjust=0, size=3)+
  geom_text(aes(label=ifelse(mem_wnomsd>2 & dispart>.2,as.character(scatterlabel),'')),hjust=0,vjust=0, size=3)+
  theme(panel.border = element_blank(), panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(), 
        axis.line = element_line(colour = "black"))+
  theme(axis.line.x = element_line(color="black", size = .5),
        axis.line.y = element_line(color="black", size = .5))+
  xlab("District Partisanship") + ylab("OC Z-Score")+
  annotation_custom(text_rep,xmin=-.25,xmax=-.25,ymin=-2.1,ymax=-2.1) + 
  annotation_custom(text_dem,xmin=.4,xmax=.4,ymin=-2.1,ymax=-2.1)+
  annotation_custom(text_con,xmin=-.35,xmax=-.35,ymin=2,ymax=2) + 
  annotation_custom(text_lib,xmin=-.38,xmax=-.38,ymin=-2,ymax=-2)+
  geom_segment(aes(x = .48, y = -2.1, xend = .5, yend = -2.1),
               arrow = arrow(length = unit(0.2, "cm")))+
  geom_segment(aes(x = -.33, y = -2.1, xend = -.35, yend = -2.1),
               arrow = arrow(length = unit(0.2, "cm")))+
  geom_segment(aes(x = -.45, y = -1.95, xend = -.45, yend = -2.05),
               arrow = arrow(length = unit(0.2, "cm")))+
  geom_segment(aes(x = -.45, y = 1.95, xend = -.45, yend = 2.05),
               arrow = arrow(length = unit(0.2, "cm")))
partyscatter

#ggsave("C:/Users/Josh Ryan/Dropbox/Committee_votes_data/Electoral Costs/tex/partyscatterplot.pdf", partyscatter)


#####
#Figure A2--Scatter plot of district partisanship and OC z-score by committee

#change education and the workforce name because it is too long
dat$Committee[dat$Committee=="Education and the Workforce"]<-"Education & Workforce"
table(dat$Committee)

plot.function <- function(df, committee = x) {
  df <- subset(dat, stewartcommid == committee)
  commname<-df[1,"Committee"]
  commname<-str_to_title(commname)
  scatterplot<-  ggplot(df, aes(x=dispart, y=mem_wnomsd, group=memberparty)) +
  geom_point(aes(shape=memberparty, color=memberparty))+
  scale_color_manual(values=c('blue','red'))+
  scale_shape_manual(values=c(19,17), labels=c("Democrats", "Republicans"))+
    guides(color=FALSE)+
    guides(shape=FALSE)+
  #labs(color = NULL)+ labs(shape = NULL)+
  scale_x_continuous(breaks=seq(-1, .5, .1))+ coord_cartesian(xlim=c(-1, .5)) +
  scale_y_continuous(breaks=seq(-2, 2, .5)) +
 # geom_smooth(aes(group=memberparty), method="lm", color = "black", size=0.5, se=FALSE)+
  #geom_smooth(method='lm', se=FALSE)+
  coord_cartesian(ylim=c(-2, 2)) + theme_bw() +
  theme(panel.border = element_blank(), panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(), 
        axis.line = element_line(colour = "black"))+
  theme(axis.line.x = element_line(color="black", size = .5),
        axis.line.y = element_line(color="black", size = .5))+
  xlab("District Partisanship") + ylab("OC Z-Score")+
    ggtitle(commname)+theme(plot.title = element_text(hjust = 0.5))
return(scatterplot)
}

table(dat$stewartcommid, dat$cong)

plot.102<-plot.function(dat, 102)
plot.104<-plot.function(dat, 104)
plot.106<-plot.function(dat, 106)
plot.113<-plot.function(dat, 113)
plot.115<-plot.function(dat, 115)
plot.124<-plot.function(dat, 124)
plot.128<-plot.function(dat, 128)
plot.134<-plot.function(dat, 134)
plot.138<-plot.function(dat, 138)
plot.142<-plot.function(dat, 142)
plot.156<-plot.function(dat, 156)
plot.164<-plot.function(dat, 164)
plot.176<-plot.function(dat, 176)
plot.182<-plot.function(dat, 182)
plot.184<-plot.function(dat, 184)
plot.192<-plot.function(dat, 192)
plot.196<-plot.function(dat, 196)
plot.242<-plot.function(dat, 242)
plot.251<-plot.function(dat, 251)


plot.all<-grid.arrange(plot.102, plot.104, plot.106, plot.113, plot.115, plot.124, plot.128, plot.134, plot.138, plot.142, plot.156, plot.164, plot.176, plot.182, plot.184, plot.196, plot.242, plot.251, ncol=4)

plot.all

#va<-subset(dat, stewartcommid==192)
#I think it's just easiest to hand save pdf size as legal, 8.4 x 14 as allcomsscatter





#Table A1-Number of Legislators With an OC Score by Committee and Congress, 104th-114th Congresses
table(dat$stewartcommid, dat$cong)
table(dat$Committee, dat$cong)
dat$memberparty<-as.factor(dat$memberparty)
tab <- addmargins(table(dat$Committee, dat$cong), 2)
print(xtable(tab), include.rownames = TRUE, type = "latex")

#Table A2-Summary Statistics of OC z-scores by congress and committee
summary(dat$mem_wnomsd)
tapply(dat$mem_wnomsd, dat$Committee, summary)
tapply(dat$mem_wnomsd, dat$cong, summary)

#these are used to create figure A3
#Figure A3 - OC Z-Score Summary Statistics by Committee and Congress
comm.max<- aggregate(dat$mem_wnomsd, list(dat$Committee), max)
comm.max$max<-comm.max$x
comm.max$Committee<-comm.max$Group.1
comm.max$x<-NULL
comm.max$Group.1<-NULL
comm.min<- aggregate(dat$mem_wnomsd, list(dat$Committee), min)
comm.min$min<-comm.min$x
comm.min$x<-NULL
comm.min$Group.1<-NULL
comm.median<- aggregate(dat$mem_wnomsd, list(dat$Committee), median)
comm.median$median<-comm.median$x
comm.median$Group.1<-NULL
comm.median$x<-NULL

comm.all<-cbind(comm.max, comm.min, comm.median)

comm.all.graph<-ggplot(comm.all, aes(x=Committee))+
  geom_linerange(aes(ymin=min,ymax=max),linetype=2,color="blue")+
  geom_errorbar(aes(ymin=min,ymax=max, width=.5), )+
  #  geom_point(aes(y=min),size=3,color="red")+
  #geom_point(aes(y=max),size=3,color="red")+
  geom_point(aes(y=median),size=1,color="gray")+
  scale_y_continuous(breaks=seq(-6, 4, 2)) +
  coord_cartesian(ylim=c(-6, 4)) +
  theme(panel.border = element_blank(), panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(), 
        panel.background = element_blank(),
        axis.line = element_line(colour = "black"))+
  theme(axis.line.x = element_line(color="black", size = .5),
        axis.line.y = element_line(color="black", size = .5))+
  xlab("") + ylab("OC Z-Scores")+
  ggtitle("By Committee")+theme(plot.title = element_text(hjust = 0.5))+
  theme(axis.text.x = element_text(angle = 45, hjust=1))

comm.all.graph


#Figure 2 - by  Congress
comm.max<- aggregate(dat$mem_wnomsd, list(dat$cong), max)
comm.max$max<-comm.max$x
comm.max$cong<-comm.max$Group.1
comm.max$x<-NULL
comm.max$Group.1<-NULL
comm.min<- aggregate(dat$mem_wnomsd, list(dat$cong), min)
comm.min$min<-comm.min$x
comm.min$x<-NULL
comm.min$Group.1<-NULL
comm.median<- aggregate(dat$mem_wnomsd, list(dat$cong), median)
comm.median$median<-comm.median$x
comm.median$Group.1<-NULL
comm.median$x<-NULL

comm.all<-cbind(comm.max, comm.min, comm.median)

comm.cong.graph<-ggplot(comm.all, aes(x=cong))+
  geom_linerange(aes(ymin=min,ymax=max),linetype=2,color="blue")+
  geom_errorbar(aes(ymin=min,ymax=max, width=.5), )+
  #  geom_point(aes(y=min),size=3,color="red")+
  #geom_point(aes(y=max),size=3,color="red")+
  geom_point(aes(y=median),size=1,color="gray")+
  scale_y_continuous(breaks=seq(-6, 4, 2)) +
  coord_cartesian(ylim=c(-6, 4)) +
  scale_x_continuous(breaks=seq(104, 114, 1)) +
  coord_cartesian(xlim=c(104, 114)) +
  theme(panel.border = element_blank(), panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(), 
        panel.background = element_blank(),
        axis.line = element_line(colour = "black"))+
  theme(axis.line.x = element_line(color="black", size = .5),
        axis.line.y = element_line(color="black", size = .5))+
  xlab("") + ylab("OC Z-Scores")+
  ggtitle("By Congress")+theme(plot.title = element_text(hjust = 0.5))+
    theme(axis.text.x = element_text(angle = 45, hjust=1))

comm.cong.graph

#plot_grid(comm.cong.graph, comm.all.graph, align = "v", nrow = 2, rel_heights = c(1/4, 3/2))


plot.comm.descriptives<-grid.arrange(comm.all.graph, comm.cong.graph, ncol=1)

#Figure A4-Distribution of District Partisanship
plot.new()
distr.dense<-hist(dat$dispart, freq=FALSE, xlim=c(-.50,.60), xlab="District Democratic Pres. Support", main="")

#error here doesn't matter
distr.dense<-distr.dense+ mtext("More Republican", side=1, line=2, adj=.1)
distr.dense<-distr.dense+mtext("More Democratic",line=2, adj=1, side=1)
#manual save, use letter size
#ggsave("C:/Users/Josh Ryan/Dropbox/Committee_votes_data/Electoral Costs/tex/partyscatterplot.pdf", partyscatter)

#Figure A5-Distribution of Proportion of Committee Controlled by Majority Party
plot.new()
distr.permaj<-hist(dat$permaj, freq=FALSE, xlim=c(.50,.75), xlab="Proportion of the Committee Controlled by the Majority Party ", main="")

#Figure A6
plot.new()
distr.commstaff<-hist(dat$congmeanstaff, freq=FALSE, xlim=c(20,160), xlab="Number of Committee Staff", main="")

#Figure A7
plot.new()
distr.commstaff<-hist(dat$congmeanstaff, freq=FALSE, xlim=c(20,160), xlab="Number of Committee Staff", main="")

plot.new()
distr.election<-hist(dat$voteshare, freq=FALSE, xlim=c(50,100), xlab="Lagged Incumbent Vote Share", main="")


#####
#Other Appendix results shown in replication file.




#labels<-subset(dat, memberparty==0 & dispart> .2 & mem_wnomsd> 2)

#labels<-labels[c("cong", "stewartcommid", "lastname", "mem_wnomsd", "Committee", "st", "cdno", "memvoted", "withparty", "unity", "totvotes")]

#dat$scatterlabel<-paste(dat$lastname, dat$Committee, dat$cong, sep=", ")
#dat$scatterlabel<-str_to_title(dat$scatterlabel)

#text_rep <- textGrob("More Republican", gp=gpar(fontsize=13))
#text_dem <- textGrob("More Democratic", gp=gpar(fontsize=13))
#text_con <- textGrob("More Conserative", gp=gpar(fontsize=13))
#text_lib <- textGrob("More Liberal", gp=gpar(fontsize=13))

#Figure A8: Scatter Plot of DW-NOMINATE and OC Z-Score by Legislator Party and Committee, 104th-114th Congresses

dwnom.corr<-ggplot(dat, aes(x=dwnom1, y=mem_wnomsd, group=memberparty)) +
  geom_point(aes(shape=memberparty, color=memberparty))+
  scale_color_manual(values=c('blue','red'), labels=c("Democrats", "Republicans"))+
  scale_shape_manual(values=c(19,17), labels=c("Democrats", "Republicans"))+
  labs(color = NULL)+ labs(shape = NULL)+
  scale_x_continuous(breaks=seq(-1, 1, .1))+ coord_cartesian(xlim=c(-1, 1)) +
  scale_y_continuous(breaks=seq(-2, 2, .5)) +
  coord_cartesian(ylim=c(-2, 2)) + theme_bw() +
  theme(panel.border = element_blank(), panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(), 
        axis.line = element_line(colour = "black"))+
  theme(axis.line.x = element_line(color="black", size = .5),
        axis.line.y = element_line(color="black", size = .5))+
  xlab("DW-Nominate Score") + ylab("OC Z-Score")
dwnom.corr

#Figure A9, Tausanovitch and Warshaw scores correlation

test<-read.csv("member_partyunit_data_v2_010721.csv") #load raw data

#load TW data from commonly used data
tw.2000<-read.csv("C:/Users/Josh Ryan/Dropbox/Commonly Used Data/TausonovitchWarshaw_ideology_estimates_v2_2000.csv")

tw.2010<-read.csv("C:/Users/Josh Ryan/Dropbox/Commonly Used Data/TausonovitchWarshaw_ideology_estimates_2010.csv")

#To merge TW data with mine, I need to make FIPS state/cd data and mine merge on FIPS
test$cdstate<-as.character(test$cdstate)

test<-test[c("cong", "cdstate", "st", "cdno", "icpsr")]

cds<-test$cdno #make as list

cds<-paste("", formatC(cds,   width=2, flag="0"), sep="") #TW data has leading zeroes, add those in

test$cds<-cds #paste back into data

test$fips<-fips(test$cdstate, to = "FIPS") #create fips for states in my data, then paste together to match TW data

test$cd_fips<-paste(test$fips, test$cds, sep="")

#now create different congresses for TW data, because they are just for every 10 year period
tw.2000$cong<-108
tw.2010$cong<-113

test.108<-merge(test, tw.2000, by=c("cd_fips", "cong"))
test.113<-merge(test, tw.2010, by=c("cd_fips", "cong"))

test.108<-test.108[c("cong", "cd_fips", "icpsr", "mrp_mean")]
test.113<-test.113[c("cong", "cd_fips", "icpsr", "mrp_mean")]

test<-rbind(test.108,test.113)

#read in main working data
alldat<-read_dta("predictpartyunitywnom_stata_v4_021721.dta")
tw.data<-merge(test, alldat, by=c("cong", "icpsr"))

tw.data$memberparty<-as.factor(tw.data$memberparty)

summary(tw.data$mrp_mean)

tw.corr<-ggplot(tw.data, aes(x=mrp_mean, y=mem_wnomsd, group=memberparty)) +
  geom_point(aes(shape=memberparty, color=memberparty))+
  scale_color_manual(values=c('blue','red'), labels=c("Democrats", "Republicans"))+
  scale_shape_manual(values=c(19,17), labels=c("Democrats", "Republicans"))+
  labs(color = NULL)+ labs(shape = NULL)+
  scale_x_continuous(breaks=seq(-1.25, .75, .25))+ coord_cartesian(xlim=c(-1.25, .75)) +
  scale_y_continuous(breaks=seq(-2, 2, .5)) +
  coord_cartesian(ylim=c(-2, 2)) + theme_bw() +
  theme(panel.border = element_blank(), panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(), 
        axis.line = element_line(colour = "black"))+
  theme(axis.line.x = element_line(color="black", size = .5),
        axis.line.y = element_line(color="black", size = .5))+
  xlab("District MRP Value") + ylab("OC Z-Score")
tw.corr

cor(tw.data$mem_wnomsd, tw.data$mrp_mean, "complete.obs")



#Figure A10, CVP z-scores scores correlation

#load TW data from commonly used data
cvp.all<-read.csv("./Management/cvp_all_v1.csv")
cvp.all$X.1<-NULL
cvp.all$X<-NULL

cvp.all$memberparty<-ifelse(cvp.all$memberparty==100,0,1)

#read in main working data
alldat<-read_dta("predictpartyunitywnom_stata_v4_021721.dta")
cvp.all<-merge(cvp.all, alldat, by=c("cong", "icpsr", "stewartcommid", "memberparty"))

cvp.all$memberparty<-as.factor(cvp.all$memberparty)

summary(cvp.all$estimate)

cvp.corr<-ggplot(cvp.all, aes(x=estimate, y=mem_wnomsd, group=memberparty)) +
  geom_point(aes(shape=memberparty, color=memberparty))+
  scale_color_manual(values=c('blue','red'), labels=c("Democrats", "Republicans"))+
  scale_shape_manual(values=c(19,17), labels=c("Democrats", "Republicans"))+
  labs(color = NULL)+ labs(shape = NULL)+
  scale_x_continuous(breaks=seq(-1.1, 1, .25))+ coord_cartesian(xlim=c(-1.1, 1)) +
  scale_y_continuous(breaks=seq(-2, 2, .5)) +
  coord_cartesian(ylim=c(-2, 2)) + theme_bw() +
  theme(panel.border = element_blank(), panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(), 
        axis.line = element_line(colour = "black"))+
  theme(axis.line.x = element_line(color="black", size = .5),
        axis.line.y = element_line(color="black", size = .5))+
  xlab("Conservative Vote Probability") + ylab("OC Z-Score")
cvp.corr

# graphing with adjusted cvp scores
cvp.adjusted.all<-read.csv("./Management/cvp_all_gls_adjusted_v1.csv")

cvp.adjusted.all$memberparty<-ifelse(cvp.adjusted.all$memberparty==100,0,1)

#read in main working data
alldat<-read_dta("predictpartyunitywnom_stata_v4_021721.dta")

cvp.adjusted.all$icpsr<-cvp.adjusted.all$ICPSR
cvp.adjusted.all$cong<-cvp.adjusted.all$Year
cvp.adjusted.all<-merge(cvp.adjusted.all, alldat, by=c("cong", "icpsr", "stewartcommid", "memberparty"))

cvp.adjusted.all$memberparty<-as.factor(cvp.adjusted.all$memberparty)

summary(cvp.adjusted.all$estimate)

cvp.corr<-ggplot(cvp.adjusted.all, aes(x=Adj.Score, y=mem_wnomsd, group=memberparty)) +
  geom_point(aes(shape=memberparty, color=memberparty))+
  scale_color_manual(values=c('blue','red'), labels=c("Democrats", "Republicans"))+
  scale_shape_manual(values=c(19,17), labels=c("Democrats", "Republicans"))+
  labs(color = NULL)+ labs(shape = NULL)+
  scale_x_continuous(breaks=seq(-1.1, 1, .25))+ coord_cartesian(xlim=c(-1.1, 1)) +
  scale_y_continuous(breaks=seq(-2, 2, .5)) +
  coord_cartesian(ylim=c(-2, 2)) + theme_bw() +
  theme(panel.border = element_blank(), panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(), 
        axis.line = element_line(colour = "black"))+
  theme(axis.line.x = element_line(color="black", size = .5),
        axis.line.y = element_line(color="black", size = .5))+
  xlab("Conservative Vote Probability") + ylab("OC Z-Score")
cvp.corr


cor(cvp.adjusted.all$mem_wnomsd, cvp.adjusted.all$Adj.Score, "complete.obs")





# graphing with adjusted cvp scores
wnom.adjusted.all<-read.csv("./Management/wnom_all_gls_adjusted_v1.csv")

wnom.adjusted.all$memberparty<-ifelse(wnom.adjusted.all$memberparty==100,0,1)

#read in main working data
alldat<-read_dta("predictpartyunitywnom_stata_v4_021721.dta")

wnom.adjusted.all$icpsr<-wnom.adjusted.all$ICPSR
wnom.adjusted.all$cong<-wnom.adjusted.all$Year
wnom.adjusted.all<-merge(wnom.adjusted.all, alldat, by=c("cong", "icpsr", "stewartcommid", "memberparty", "wnomestimate"))

wnom.adjusted.all$memberparty<-as.factor(wnom.adjusted.all$memberparty)

summary(wnom.adjusted.all$estimate)

wnom.adjusted.all<-subset(wnom.adjusted.all, Adj.Score>-1 & Adj.Score<1)
summary(wnom.adjusted.all$Adj.Score)

wnom.corr<-ggplot(wnom.adjusted.all, aes(x=Adj.Score, y=mem_wnomsd, group=memberparty)) +
  geom_point(aes(shape=memberparty, color=memberparty))+
  scale_color_manual(values=c('blue','red'), labels=c("Democrats", "Republicans"))+
  scale_shape_manual(values=c(19,17), labels=c("Democrats", "Republicans"))+
  labs(color = NULL)+ labs(shape = NULL)+
  scale_x_continuous(breaks=seq(-1, 1, .25))+ coord_cartesian(xlim=c(-1, 1)) +
  scale_y_continuous(breaks=seq(-2, 2, .5)) +
  coord_cartesian(ylim=c(-2, 2)) + theme_bw() +
  theme(panel.border = element_blank(), panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(), 
        axis.line = element_line(colour = "black"))+
  theme(axis.line.x = element_line(color="black", size = .5),
        axis.line.y = element_line(color="black", size = .5))+
  xlab("Conservative Vote Probability") + ylab("OC Z-Score")
wnom.corr


cor(wnom.adjusted.all$mem_wnomsd, wnom.adjusted.all$Adj.Score, "complete.obs")

